//
// Simple Javascript filter framework. Uses JQuery and PHP.JS.
// 
// Usage: put the tag filter="negative_number" (for instance) and
// filter.js will do the magic.
// 


// Possibles filters:
var DDD_FILTER_REGEXS = {
  negative_number: /[\d\-]/,
  positive_number: /[\d\.]/,
  email:           /[a-z0-9_\.\-@]/i,
  only_letters:    /[a-zA-Z ]/i,
  only_letters_and_number: /[a-zA-Z0-9\. ]/i
};


function ddd_filter() {
  $("*[filter]").keypress(function(event) {
    var filter = DDD_FILTER_REGEXS[$(this).attr("filter")];
    if (filter.test(chr(event.which))) { return true; } 
    else { return false; };   
  });
}

